<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    img {
        width: 500px;
        height: 300px;
    }
</style>

<body>
    <img src="img/早上好.jpg" alt="">
    <div>早上好</div>

    <script>
        //1.获取元素
        var img = document.querySelector('img')
        var div = document.querySelector('div')
        //2.获取系统当前时间
        var time = new Date();
        var h = time.getHours();
        //3.判断
        if (h < 12 && h > 6) {
            div.innerHTML = '早上好'
            img.src = 'img/早上好.jpg'
        }
        else if (h > 12 && h < 18) {
            div.innerHTML = '下午好'
            img.src = 'img/下午好.jpg'
        }
        else {
            div.innerHTML = '晚上好'
            img.src = 'img/晚上好.jpg'
        }
    </script>
</body>

</html>